package org.come.login;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTextField;

import org.come.bean.UserRoleArrBean;
import org.come.view.View;

public class IphoneView extends View {

    private SpriteBtn affirmBtn,// 确认按钮
            backGroundImg;// 背景图片
    private JTextField verificationText;// 验证码
    private JLabel labMsgTip;// 放置提示信息
    private UserRoleArrBean arrBean;// 存储后端发来的信息

    public IphoneView(LoginJpanel loginJpanel, UserRoleArrBean arrBean) {
        this.setPreferredSize(new Dimension(530, 168));
        this.setLayout(null);
        this.arrBean = arrBean;
        backGroundImg = new SpriteBtn("resource/NewUi/底板_登录界面验证_w530,h168px", 0, 0, false);
        backGroundImg.setBounds(0, 0, 530, 168);
        this.add(backGroundImg);

        // 放置提示信息
        labMsgTip = new JLabel();
        labMsgTip.setBounds(370, 75, 300, 30);
        labMsgTip.setFont(new Font("楷体", 1, 16));
        labMsgTip.setForeground(Color.red);
        this.add(labMsgTip);
        // 验证码
        verificationText = new JTextField();
        verificationText.setBounds(265, 75, 102, 23);
        verificationText.setOpaque(false);
        verificationText.setBorder(BorderFactory.createEmptyBorder());
        verificationText.setForeground(Color.WHITE);
        verificationText.setFont(new Font("宋体", 0, 14));
        verificationText.setCaretColor(Color.WHITE);// 设置光标颜色为白色
        verificationText.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {
            }

            @Override
            public void keyReleased(KeyEvent e) {
                if (verificationText.getText() != null) {
                    if ("".equalsIgnoreCase(verificationText.getText())) {
                        labMsgTip.setText("");
                    }
                } else {
                    labMsgTip.setText("请输入验证码！");
                }

            }

            @Override
            public void keyPressed(KeyEvent e) {
            }
        });
        this.add(verificationText);

        affirmBtn = new SpriteBtn("resource/NewUi/按钮_确定3", 170, 106, false);
        affirmBtn.setBounds(170, 106, 192, 52);
        affirmBtn.addMouseListener(new LoginMouslisten(7, affirmBtn, loginJpanel));
        this.add(affirmBtn);

    }

    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponent(g);
        backGroundImg.draw(g);
        affirmBtn.draw(g);
    }

    public UserRoleArrBean getArrBean() {
        return arrBean;
    }

    public void setArrBean(UserRoleArrBean arrBean) {
        this.arrBean = arrBean;
    }

    public JTextField getVerificationText() {
        return verificationText;
    }

    public void setVerificationText(JTextField verificationText) {
        this.verificationText = verificationText;
    }

    public JLabel getLabMsgTip() {
        return labMsgTip;
    }

    public void setLabMsgTip(JLabel labMsgTip) {
        this.labMsgTip = labMsgTip;
    }

}
